package com.bjl.controller;

import com.alibaba.fastjson.JSONObject;
import com.bjl.service.DealService;
import com.bjl.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import orm.base.Ex.BaseControllerEx;

import java.util.Map;

/**
 * Created by ashin on 2017/11/22.
 */
@Controller
@Scope("prototype")
@RequestMapping("/room")
public class RoomController extends BaseControllerEx {

    @Autowired
    RoomService roomService;

    @Override
    protected void init() {
        super.init(roomService);
    }

    /**
     * 查询娱乐聊天室列表
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doQueryRecreationChartRooms", method = RequestMethod.POST)
    public JSONObject doQueryRecreationChartRooms(@RequestParam Map map) throws Exception{
        return roomService.queryRecreationChartRooms(map,session);
    }

    /**
     * 查询普通聊天室列表
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doQueryNormalChartRooms", method = RequestMethod.POST)
    public JSONObject doQueryNormalChartRooms(@RequestParam Map map) throws Exception{
        return roomService.queryNormalChartRooms(map,session);
    }

    @Override
    protected JSONObject doQuery(@RequestParam Map map) throws Exception {
        return roomService.query(map,session);
    }

    @Override
    protected JSONObject doPageQuery(@RequestParam(required = false) Map map) throws Exception {
        return roomService.pagequery(map,session);
    }

    /**
     * 将用户添加到房间
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doAddUserRoom", method = RequestMethod.POST)
    public JSONObject doAddUserRoom(@RequestParam Map map) throws Exception{
        return roomService.addUserRoom(map,session);
    }

    /**
     * 将用户移除出房间
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doRemoveUserRoom", method = RequestMethod.POST)
    public JSONObject doRemoveUserRoom(@RequestParam Map map) throws Exception{
        return roomService.removeUserRoom(map,session);
    }
}
